Conditions | 8 |
Paths | 14 |
Total Lines | 84 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | var program = require('commander'); |
||
14 | if ( enviroment === 'dev' ){ |
||
15 | |||
16 | vagrantId = shell.exec("vagrant global-status | grep d1b0server | awk '{ print $1}'", {silent:true}); |
||
|
|||
17 | |||
18 | var vagrantCode; |
||
19 | if ( vagrantId.code !== 0 ){ |
||
20 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore: "+vagrantId.stderr+ " - "+vagrantId.output))); |
||
21 | process.exit(1); |
||
22 | } else { |
||
23 | vagrantCode = vagrantId.output.trim(); |
||
24 | } |
||
25 | |||
26 | if ( !vagrantCode ) { |
||
27 | process.stdout.write(chalk.yellow(emoji.emojify("[:raised_hand: ] Vagrant server not found \n"))); |
||
28 | |||
29 | shell.exec('./scripts/generatekey.sh'); |
||
30 | shell.exec('./scripts/generateSSL.sh'); |
||
31 | shell.exec('./scripts/roles_update.sh'); |
||
32 | |||
33 | shell.cd('server/'); |
||
34 | |||
35 | upVagrant = shell.exec("vagrant up", {silent:true}); |
||
36 | if ( upVagrant.code !== 0 ){ |
||
37 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore: "+upVagrant.stderr+ " - "+upVagrant.output))); |
||
38 | process.exit(1); |
||
39 | } |
||
40 | |||
41 | process.stdout.write("Vagrant server UP.\n"); |
||
42 | |||
43 | |||
44 | shell.echo('Install Server Required Package and Config'); |
||
45 | ansibleProc = shell.exec('ansible-playbook -i '+enviroment+'.hosts site.yml', {silent:true}); |
||
46 | if ( ansibleProc.code !== 0 ){ |
||
47 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore ansible site.yml"))); |
||
48 | process.stderr.write(chalk.gray(ansibleProc.stdout+"\n")); |
||
49 | process.stderr.write(chalk.red(ansibleProc.stderr+"\n")); |
||
50 | |||
51 | process.exit(1); |
||
52 | } |
||
53 | |||
54 | process.stdout.write(chalk.bgGreen.black(emoji.emojify('[:heavy_check_mark: ] Vagrant server installation packages completed.' + "\n"))); |
||
55 | |||
56 | shell.cd('..'); |
||
57 | |||
58 | } else { |
||
59 | process.stdout.write(chalk.gray(emoji.emojify("[:world_map: ] Find vagrant server: "+vagrantCode+". Skip creation.\n" ))); |
||
60 | // non funziona vagrant up by name or uuid |
||
61 | // var upVagrant = shell.exec("vagrant up "+vagrantCode); |
||
62 | |||
63 | shell.cd('server/'); |
||
64 | |||
65 | upVagrant = shell.exec("vagrant up", {silent:true}); |
||
66 | if ( upVagrant.code !== 0 ){ |
||
67 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore ansible site.yml"))); |
||
68 | process.stderr.write(chalk.gray(ansibleProc.stdout+"\n")); |
||
69 | process.stderr.write(chalk.red(ansibleProc.stderr+"\n")); |
||
70 | process.exit(1); |
||
71 | } |
||
72 | |||
73 | process.stdout.write(chalk.bgGreen.black(emoji.emojify('[:heavy_check_mark: ] Vagrant server UP!' + "\n"))); |
||
74 | |||
75 | shell.cd('..'); |
||
76 | } |
||
77 | |||
78 | } else { |
||
79 | |||
80 | shell.echo('Install Server Required Package and Config'); |
||
81 | ansibleProc = shell.exec('ansible-playbook -i '+enviroment+'.hosts site.yml', {silent:true}); |
||
82 | if ( ansibleProc.code !== 0 ){ |
||
83 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore: "+ansibleProc.stderr+ " - "+ansibleProc.output))); |
||
84 | process.exit(1); |
||
85 | } |
||
86 | |||
87 | } |
||
88 |